package components.utils.observer;

import java.util.Collection;
import javax.swing.DefaultListModel;
import javax.swing.JList;

public class ListUpdater extends CollectionObserver {
    
    private JList list;

    public ListUpdater(Collection collection, JList list) {
        super(collection);
        this.list = list;
    }

    @Override
    public void notifyObserver() {
        DefaultListModel model = new DefaultListModel();
        for (Object entity : collection) {
            model.addElement(entity);
        }
        list.setModel(model);
    }

}
